<?php
class Fax extends MY_Controller{
	
	function __construct()
	{
		parent::__construct();
	}
	
	
	function index()
	{
		/**************** Settings begin **************/

		$username = 'bobhao'; // Enter your Interfax username here
		$password = 'geniush2002'; // Enter your Interfax password here
		$faxnumber = '003227065373'; // Enter your designated fax number here in the format +[country code][area code][fax number], for example: +12125554874
		//$texttofax = 'My text goes here'; // Enter your fax contents here
		$filename = 'application/order_files/order_'.str_pad(17, 7, '0', STR_PAD_LEFT).'.pdf';
		$filetype = 'PDF'; // If $texttofax is regular text, enter TXT here. If $texttofax is HTML enter HTML here
			
		/**************** Settings end ****************/
		// Open File
		if( !($fp = fopen($filename, "r"))){
			// Error opening file
			echo "Error opening file";
			exit;
		}

		// Read data from the file into $data
		$data = "";
		while (!feof($fp)) $data .= fread($fp,1024);
		fclose($fp);

		$client = new SoapClient("http://ws.interfax.net/dfs.asmx?wsdl");
		$params = new stdClass();
		$params->Username  = $username;
		$params->Password  = $password;
		$params->FaxNumber = $faxnumber;
		//$params->Data      = $texttofax;
		$params->FileData  = $data;
		$params->FileType  = $filetype;

		$result = $client->Sendfax($params);
		if($result->SendfaxResult>0){
			echo 'happy';
		}else{
		echo 'hell';
		}
	}

	function faxquery()
	{
		/**************** Settings begin **************/
		$user_data = fax_account::find('all');
		$username = $user_data[0]->username;  // Enter your Interfax username here
		$password = $user_data[0]->password;   // Enter your Interfax password here
		$query_verb = 'LT'; // Very flexible, see documentation
		$query_data = '999999999';  //
		$max_items  = '10';

		/**************** Settings end ****************/

		$client = new SoapClient("http://ws.interfax.net/dfs.asmx?wsdl");
		$params = new stdClass();
		$params->Username   = $username;
		$params->Password   = $password;
		$params->Verb       = $query_verb;
		$params->VerbData   = $query_data;
		$params->MaxItems   = $max_items;
		$params->ResultCode = '';

		$queryResult = $client->FaxQuery($params);
		$queryCount = count($queryResult->FaxQueryResult->FaxItemEx);

		// Format information retrieved from InterFAX

		if (0 == $queryResult->ResultCode){ // status request succeeded
			switch($queryCount){
				case 0:
					echo 'No transactions fit query';
					break;

				case 1:	// single item returned by WS call
					echo 'ParentTransactionID: ' . $queryResult->FaxQueryResult->FaxItemEx->ParentTransactionID . '<br />';
					echo 'TransactionID: ' . $queryResult->FaxQueryResult->FaxItemEx->TransactionID . '<br />';
					echo 'SubmitTime: ' . $queryResult->FaxQueryResult->FaxItemEx->SubmitTime . '<br />';
					echo 'CompletionTime: ' . $queryResult->FaxQueryResult->FaxItemEx->PostponeTime . '<br />';
					echo 'CompletionTime: ' . $queryResult->FaxQueryResult->FaxItemEx->CompletionTime . '<br />';
					echo 'UserID: ' . $queryResult->FaxQueryResult->FaxItemEx->UserID . '<br />';
					echo 'Contact: ' . $queryResult->FaxQueryResult->FaxItemEx->Contact . '<br />';
					echo 'DestinationFax: ' . $queryResult->FaxQueryResult->FaxItemEx->DestinationFax . '<br />';
					echo 'ReplyEmail: ' . $queryResult->FaxQueryResult->FaxItemEx->ReplyEmail . '<br />';
					echo 'RemoteCSID: ' . $queryResult->FaxQueryResult->FaxItemEx->RemoteCSID . '<br />';
					echo 'PagesSent: ' . $queryResult->FaxQueryResult->FaxItemEx->PagesSent . '<br />';
					echo 'Status: ' . $queryResult->FaxQueryResult->FaxItemEx->Status . '<br />';
					echo 'Duration: ' . $queryResult->FaxQueryResult->FaxItemEx->Duration . '<br />';
					echo 'Subject: ' . $queryResult->FaxQueryResult->FaxItemEx->Subject . '<br />';
					echo 'PagesSubmitted: ' . $queryResult->FaxQueryResult->FaxItemEx->PagesSubmitted . '<br />';
					echo 'SenderCSID: ' . $queryResult->FaxQueryResult->FaxItemEx->SenderCSID . '<br />';
					echo 'Priority: ' . $queryResult->FaxQueryResult->FaxItemEx->Priority . '<br />';
					echo 'Units: ' . $queryResult->FaxQueryResult->FaxItemEx->Units . '<br />';
					echo 'CostPerUnit: ' . $queryResult->FaxQueryResult->FaxItemEx->CostPerUnit . '<br />';
					echo 'PageSize: ' . $queryResult->FaxQueryResult->FaxItemEx->PageSize . '<br />';
					echo 'PageOrientation: ' . $queryResult->FaxQueryResult->FaxItemEx->PageOrientation . '<br />';
					echo 'PageResolution: ' . $queryResult->FaxQueryResult->FaxItemEx->PageResolution . '<br />';
					echo 'RenderingQuality: ' . $queryResult->FaxQueryResult->FaxItemEx->RenderingQuality . '<br />';
					echo 'PageHeader: ' . $queryResult->FaxQueryResult->FaxItemEx->PageHeader . '<br />';
					echo 'RetriesToPerform: ' . $queryResult->FaxQueryResult->FaxItemEx->RetriesToPerform . '<br />';
					echo 'TrialsPerformed: ' . $queryResult->FaxQueryResult->FaxItemEx->TrialsPerformed . '<br />';
					break;

				default: // multiple items returned by WS call
					for($i = 0; $i < $queryCount; $i++){
						echo 'ParentTransactionID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->ParentTransactionID . '<br />';
						echo 'TransactionID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->TransactionID . '<br />';
						echo 'SubmitTime: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->SubmitTime . '<br />';
						echo 'CompletionTime: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PostponeTime . '<br />';
						echo 'CompletionTime: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->CompletionTime . '<br />';
						echo 'UserID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->UserID . '<br />';
						echo 'Contact: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Contact . '<br />';
						echo 'DestinationFax: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->DestinationFax . '<br />';
						echo 'ReplyEmail: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->ReplyEmail . '<br />';
						echo 'RemoteCSID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->RemoteCSID . '<br />';
						echo 'PagesSent: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PagesSent . '<br />';
						echo 'Status: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Status . '<br />';
						echo 'Duration: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Duration . '<br />';
						echo 'Subject: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Subject . '<br />';
						echo 'PagesSubmitted: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PagesSubmitted . '<br />';
						echo 'SenderCSID: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->SenderCSID . '<br />';
						echo 'Priority: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Priority . '<br />';
						echo 'Units: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->Units . '<br />';
						echo 'CostPerUnit: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->CostPerUnit . '<br />';
						echo 'PageSize: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PageSize . '<br />';
						echo 'PageOrientation: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PageOrientation . '<br />';
						echo 'PageResolution: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PageResolution . '<br />';
						echo 'RenderingQuality: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->RenderingQuality . '<br />';
						echo 'PageHeader: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->PageHeader . '<br />';
						echo 'RetriesToPerform: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->RetriesToPerform . '<br />';
						echo 'TrialsPerformed: ' . $queryResult->FaxQueryResult->FaxItemEx[$i]->TrialsPerformed . '<br />';
						echo '------------------------------------<br />';
					}  // close loop
					break;
			}  // close switch
		} else { // problem getting status
			// Do something here, like alerting an administrator
			echo 'Problem retrieving status';
		}

	}


	function faxquery2()
	{

		/**************** Settings begin **************/
		// See http://www.interfax.net/en/dev/webservice/reference/faxquery2
		// for an explanation of properties

		// Valid values for [property]_verb are:
		// Equals | GreaterThan | GreaterOrEqual | LessThan | LessOrEqual | Like | IncludedIn | Between
		// Leave both [property]_verb and [property]_data empty to ignore the property in the query

		$username = 'bobhao';
		$password = 'geniush2002';

		$subject_verb = '';
		$subject_data = '';

		$faxnumber_verb = '';
		$faxnumber_data = '';

		$date_from = '';
		$date_to = '';

		$user_id_verb = '';
		$user_id_data = '';

		$reply_address_verb = '';
		$reply_address_data = '';

		$transaction_id_verb = '';
		$transaction_id_data = '';

		$parent_transaction_id_verb = '';
		$parent_transaction_id_data = '';

		$status_verb = '';
		$status_data = '';

		// The following values control display settings

		$show_hidden_transactions = TRUE;
		$only_parents = FALSE;
		$num_of_results = 100;
		$starting_record = 0;

		// Valid values for $order_by are:
		// TransactionID | SubmitTime | CompletionTime | Status | DestinationFax | Subject | PagesSent | UserID | ReplyEmail

		$order_by = 'TransactionID';
		$asc_order_direction = TRUE;
		$return_items = TRUE;
		$return_stats = TRUE;

		/**************** Settings end **************/

		// Set default values for empty query properties

		if(!($subject_verb && $subject_data)){
			$subject_verb = 'Equals';
			$subject_data = '';
		}

		if(!($faxnumber_verb && $faxnumber_data)){
			$faxnumber_verb = 'Equals';
			$faxnumber_data = '';
		}

		if(!$date_from) $date_from = '1999-01-01T00:00:01';

		if(!$date_to) $date_to = '2999-12-31T23:59:59';

		if(!($user_id_verb && $user_id_data)){
			$user_id_verb = 'Equals';
			$user_id_data = '';
		}

		if(!($reply_address_verb && $reply_address_data)){
			$reply_address_verb = 'Equals';
			$reply_address_data = '';
		}

		if(!($transaction_id_verb && $transaction_id_data)){
			$transaction_id_verb = 'Equals';
			$transaction_id_data = '';
		}

		if(!($parent_transaction_id_verb && $parent_transaction_id_data)){
			$parent_transaction_id_verb = 'Equals';
			$parent_transaction_id_data = '';
		}

		if(!($status_verb && !is_null($status_data))){
			$status_verb = 'Equals';
			$status_data = '';
		}

		// End setting default values
		$params = new stdClass();
		$params->QueryForm = new stdClass();
		$params->QueryForm->Subject = new stdClass();
		$params->QueryForm->FaxNumber = new stdClass();
		$params->QueryForm->UserID = new stdClass();
		$params->QueryForm->ReplyAddress = new stdClass();
		$params->QueryForm->TransactionID = new stdClass();
		$params->QueryForm->ParentTransactionID = new stdClass();
		$params->QueryForm->Status = new stdClass();
		$params->QueryControl = new stdClass();
		$params->Username                                 = $username;
		$params->Password                                 = $password;
		$params->QueryForm->Subject->Verb                 = $subject_verb;
		$params->QueryForm->Subject->VerbData             = $subject_data;
		$params->QueryForm->FaxNumber->Verb               = $faxnumber_verb;
		$params->QueryForm->FaxNumber->VerbData           = $faxnumber_data;
		$params->QueryForm->DateFrom                      = $date_from;
		$params->QueryForm->DateTo                        = $date_to;
		$params->QueryForm->UserID->Verb                  = $user_id_verb;
		$params->QueryForm->UserID->VerbData              = $user_id_data;
		$params->QueryForm->ReplyAddress->Verb            = $reply_address_verb;
		$params->QueryForm->ReplyAddress->VerbData        = $reply_address_data;
		$params->QueryForm->TransactionID->Verb           = $transaction_id_verb;
		$params->QueryForm->TransactionID->VerbData       = $transaction_id_data;
		$params->QueryForm->ParentTransactionID->Verb     = $parent_transaction_id_verb;
		$params->QueryForm->ParentTransactionID->VerbData = $parent_transaction_id_data;
		$params->QueryForm->Status->Verb                  = $status_verb;
		$params->QueryForm->Status->VerbData              = $status_data;
		$params->QueryForm->ShowHiddenTransactions        = $show_hidden_transactions;
		$params->QueryControl->OnlyParents                = $only_parents;
		$params->QueryControl->NumOfResults               = $num_of_results;
		$params->QueryControl->StartingRecord             = $starting_record;
		$params->QueryControl->OrderBy                    = $order_by;
		$params->QueryControl->AscOrderDirection          = $asc_order_direction;
		$params->QueryControl->ReturnItems                = $return_items;
		$params->QueryControl->ReturnStats                = $return_stats;


		$client = new SoapClient("http://ws.interfax.net/dfs.asmx?wsdl");

		// Use the call below to trace PHP's SOAP call
		// $client = new SoapClient("http://ws.interfax.net/dfs.asmx?wsdl", array('trace' => 1));

		$queryResult = $client->FaxQuery2($params);

		// Display the SOAP call; use in conjunction with the alternative SOAP call above
		// echo $client->__getLastRequest();

		// Format and present retrieved data

		if ($queryResult->FaxQuery2Result->ResultCode == 0){ // status request succeeded

			if ($return_stats){
				echo '<h1>Stats</h1>';
				$statsCount = count($queryResult->FaxQuery2Result->Stats->StatusCount);

				switch($statsCount){
					case 0:
						echo 'No transactions fit query';
						break;

					case 1:
						echo 'Status ' . $queryResult->FaxQuery2Result->Stats->StatusCount->Status . ' :';
						echo $queryResult->FaxQuery2Result->Stats->StatusCount->Count . '<br />';
						break;

					default:
						for($j = 0; $j < $statsCount; $j++){
							echo 'Status ' . $queryResult->FaxQuery2Result->Stats->StatusCount[$j]->Status . ' :';
							echo $queryResult->FaxQuery2Result->Stats->StatusCount[$j]->Count . '<br/>';
						}
						break;
				}
			}

			if ($return_items){

				$queryCount = count($queryResult->FaxQuery2Result->FaxItems->FaxItemEx2);
				echo '<h1>Details</h1>';
				switch($queryCount){
					case 0:
						echo 'No transactions fit query';
						break;

					case 1:	// single item returned by WS call
						echo 'ParentTransactionID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->ParentTransactionID . '<br />';
						echo 'TransactionID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->TransactionID . '<br />';
						echo 'SubmitTime: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->SubmitTime . '<br />';
						echo 'PostponeTime: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->PostponeTime . '<br />';
						echo 'CompletionTime: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->CompletionTime . '<br />';
						echo 'UserID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->UserID . '<br />';
						echo 'Contact: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->Contact . '<br />';
						echo 'Job ID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->JobID . '<br />';
						echo 'DestinationFax: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->DestinationFax . '<br />';
						echo 'ReplyEmail: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->ReplyEmail . '<br />';
						echo 'RemoteCSID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->RemoteCSID . '<br />';
						echo 'PagesSent: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->PagesSent . '<br />';
						echo 'Status: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->Status . '<br />';
						echo 'Duration: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->Duration . '<br />';
						echo 'Subject: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->Subject . '<br />';
						echo 'PagesSubmitted: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->PagesSubmitted . '<br />';
						echo 'SenderCSID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->SenderCSID . '<br />';
						echo 'Priority: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->Priority . '<br />';
						echo 'Units: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->Units . '<br />';
						echo 'CostPerUnit: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->CostPerUnit . '<br />';
						echo 'PageSize: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->PageSize . '<br />';
						echo 'PageOrientation: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->PageOrientation . '<br />';
						echo 'PageResolution: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->PageResolution . '<br />';
						echo 'RenderingQuality: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->RenderingQuality . '<br />';
						echo 'PageHeader: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->PageHeader . '<br />';
						echo 'RetriesToPerform: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->RetriesToPerform . '<br />';
						echo 'TrialsPerformed: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->TrialsPerformed . '<br />';
						echo 'LocaleID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->LocaleID . '<br />';
						echo 'GMTBias: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->GMTBias . '<br />';
						echo 'RetriesInterval: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->RetriesInterval . '<br />';
						echo 'UserData: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->UserData . '<br />';
						echo 'DeleteAfterUsage: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->DeleteAfterUsage . '<br />';
						echo 'Mode: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->Mode . '<br />';
						echo 'NumOfTransactions: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->NumOfTransactions . '<br />';
						echo 'MessageID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2->MessageID . '<br />';
						break;

					default: // multiple items returned by WS call
						for($i = 0; $i < $queryCount; $i++){
							echo 'ParentTransactionID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->ParentTransactionID . '<br />';
							echo 'TransactionID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->TransactionID . '<br />';
							echo 'SubmitTime: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->SubmitTime . '<br />';
							echo 'PostponeTime: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->PostponeTime . '<br />';
							echo 'CompletionTime: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->CompletionTime . '<br />';
							echo 'UserID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->UserID . '<br />';
							echo 'Contact: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->Contact . '<br />';
							echo 'Job ID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->JobID . '<br />';
							echo 'DestinationFax: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->DestinationFax . '<br />';
							echo 'ReplyEmail: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->ReplyEmail . '<br />';
							echo 'RemoteCSID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->RemoteCSID . '<br />';
							echo 'PagesSent: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->PagesSent . '<br />';
							echo 'Status: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->Status . '<br />';
							echo 'Duration: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->Duration . '<br />';
							echo 'Subject: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->Subject . '<br />';
							echo 'PagesSubmitted: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->PagesSubmitted . '<br />';
							echo 'SenderCSID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->SenderCSID . '<br />';
							echo 'Priority: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->Priority . '<br />';
							echo 'Units: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->Units . '<br />';
							echo 'CostPerUnit: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->CostPerUnit . '<br />';
							echo 'PageSize: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->PageSize . '<br />';
							echo 'PageOrientation: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->PageOrientation . '<br />';
							echo 'PageResolution: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->PageResolution . '<br />';
							echo 'RenderingQuality: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->RenderingQuality . '<br />';
							echo 'PageHeader: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->PageHeader . '<br />';
							echo 'RetriesToPerform: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->RetriesToPerform . '<br />';
							echo 'TrialsPerformed: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->TrialsPerformed . '<br />';
							echo 'LocaleID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->LocaleID . '<br />';
							echo 'GMTBias: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->GMTBias . '<br />';
							echo 'RetriesInterval: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->RetriesInterval . '<br />';
							echo 'UserData: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->UserData . '<br />';
							echo 'DeleteAfterUsage: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->DeleteAfterUsage . '<br />';
							echo 'Mode: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->Mode . '<br />';
							echo 'NumOfTransactions: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->NumOfTransactions . '<br />';
							echo 'MessageID: ' . $queryResult->FaxQuery2Result->FaxItems->FaxItemEx2[$i]->MessageID . '<br />';
							echo '------------------------------------<br />';
						}  // close loop
						break;
				}  // close switch
			}
		} else { // problem getting status
			// Do something here, like alerting an administrator
			echo 'Problem retrieving status, error <a href="http://www.interfax.net/en/dev/webservice/reference/web-service-return-codes">' . $queryResult->FaxQuery2Result->ResultCode . '</a>';
		}




	}
	
	
	function user_data ()
	{
		
		$user_data = fax_account::find('all');
		
		echo var_dump($user_data);
		
		
	}
	
	function address()
	{
		$this->load->view('address_api');
	}

}